package cn.jinjie.day09;

import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Test08 {
    public static void main(String[] args) {
        ArrayList<Integer> al = new ArrayList<>();
        for (int i = 1; i <= 10; i++) {
            al.add(i);
        }
        //添加一些重复数据  为了后面set集合演示去重复
        al.add(10);
        al.add(10);
        al.add(10);
        al.add(10);
        // System.out.println(al);
        List<Integer> list01 = al.stream().filter(integer -> integer % 2 == 0).collect(Collectors.toList());
        System.out.println(list01);

        Set<Integer> set01 = al.stream().filter(integer -> integer % 2 == 0).collect(Collectors.toSet());
        System.out.println(set01);

        Object[] objects = al.stream().filter(integer -> integer % 2 == 0).toArray();
        System.out.println(Arrays.toString(objects));

        // Integer[] i1 = al.stream().filter(integer -> integer % 2 == 0).toArray(value -> new Integer[value]);
        Integer[] i1 = al.stream().filter(integer -> integer % 2 == 0).toArray(Integer[]::new);
        System.out.println(Arrays.toString(i1));

    }
}
